import sys
from copy import deepcopy

# add element
l = []
p = id(l)
i = 0
while len(l) < 3:
    l.append(i := i + 1)
for i in range(3):
    l.insert(i, l[i])
print(f"{l = }")
print(f'{p} {"==" if p == id(l) else "!="} {id(l)}')

# delete element
l2 = l
l2.clear()
print(f"{sys.getrefcount(l) = }")
print(f"{l = }")
l = [3, 2, 1, 2]
print(f"{l.count(2) = }")
print(f"{l2 = }")
l.remove(2)
print(f"{l.pop(0) = }")
del l[1:2]
print(f"{l = }")

# search element
l3 = list(range(1, 10, 3))
print(f"{l3 = }")
print(f"{l3[1] = }, {l3[-1] = }, {l3.index(1) = }")
l3[1] = 6
print(f"{l3[1] = }")

# reverse list
rl = l3[::-1]
l3.reverse()
print(f"{rl == l3 = }")

# copy list
l = [1, 2, 3, 4, 5]
l2 = l.copy()
print(f"{id(l) == id(l2) = }")
l3 = list(l)
print(f"{id(l) == id(l3) = }")
l4 = l[:]
print(f"{id(l) == id(l4) = }")
l5 = deepcopy(l)
print(f"{id(l) == id(l5) = }")

# extend list
l = [-2]
l = l + [2, 3, 3]
l += [6, 6, 6]
l[-1:] = [0, 0, 0]
l.extend([2, 5, 0])
l = l * 2
l *= 2
print(f"{l = }")

# change order
l = [1, 7, 3, 5, 9, 4]
print(f"{max(l) = }, {min(l) = }")
l.sort()
print(f"{l = }")
sl = list("hello")
sl.reverse()
print(f"{sl = }")

# merge list
l1 = [1, 2, 3]
l2 = [4, 5, 6]
print(f"{list(zip(l1,l2)) = }")
